﻿#include <iostream>
#include <memory>

class Resource {
public:
    Resource() { std::cout << "create\n"; }
    ~Resource() { std::cout << "xiaohui\n"; }
};

int main() {
    std::unique_ptr<Resource> res1 = std::make_unique<Resource>();
    // std::unique_ptr<Resource> res2 = res1; // ❌ 错误：不能复制
    std::unique_ptr<Resource> res2 = std::move(res1); // ✅ 转移所有权
    if (!res1) std::cout << "res1 kong\n";
    return 0;
}
